package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.biz.UserInfoBiz;
import com.oepm.dao.entity.DictionaryPo;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.entity.UserInfoPo;
import com.oepm.dao.entity.vo.UserPassVo;
import com.oepm.dao.mapper.UserInfoMapper;
import com.oepm.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserInfoBizIml implements UserInfoBiz {
    @Resource
    UserInfoMapper userInfoMapper;

    @Override
    public UserInfoPo queryById(String userId) {
        return userInfoMapper.queryById(userId);
    }

    @Override
    public String queryUserId(String id) {
        return userInfoMapper.queryUserId(id);
    }

    @Override
    public int insertInfo(DictionaryPo dp) {
        return userInfoMapper.insertInfo(dp);
    }

    @Override
    public int updateInfo(DictionaryPo dp) {
        return userInfoMapper.updateInfo(dp);
    }

    @Override
    public DataVo queryUserAll(QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<UserInfoPo> userInfoPos = userInfoMapper.queryUserAll();
        PageInfo<UserInfoPo> pi = new PageInfo<>(userInfoPos);

        return new DataVo(pi.getTotal(),pi.getList());
    }

    @Override
    public String selectPass(String userId) {
        return userInfoMapper.selectPass(userId);
    }

    @Override
    public int updatePass(UserPassVo userPassVo) {
        return userInfoMapper.updatePass(userPassVo);
    }
}
